from sqlalchemy import String
from sqlalchemy.orm import Mapped, mapped_column, relationship

from src.database.models.base import TimedBaseModel


class Country(TimedBaseModel):
    __tablename__ = "country"
    __mapper_args__ = {"eager_defaults": True}

    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str] = mapped_column(String(255), nullable=False)
    categories = relationship("Category", back_populates="country")

    def __repr__(self):
        return f"<Страна {self.name}>"

    def __str__(self):
        return self.__repr__()
